<%@page import="java.sql.ResultSet"%>
<%@ page import="java.util.Date" language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page session="true" %>

<%@ page contentType="text/html; charset=UTF-8" import="com.mysql.jdbc.*"%>
<%@ page contentType="text/html; charset=UTF-8" import="java.sql.Connection"%>
<%@ page contentType="text/html; charset=UTF-8" import="java.sql.DriverManager"%>
<%@ page contentType="text/html; charset=UTF-8" import="java.sql.Statement"%>

<%!
	public int join(String _strId, String _strPwd, String _strEmail, String _strMe2dayId){
		Connection con;
	    Statement stmt;
	 	int ret = 0;
	    try
	    {
	    	Class.forName("com.mysql.jdbc.Driver").newInstance(); 
			Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mimo" ,"root" ,"d0o9o84");
	        
	        stmt = conn.createStatement();
	        
	        stmt.execute("insert into user(userId,attName,value) values('" + _strId + "', 'password', '" + _strPwd + "');");
	        stmt.execute("insert into user(userId,attName,value) values('" + _strId + "', 'me2dayId', '" + _strMe2dayId + "');");
	        stmt.execute("insert into user(userId,attName,value) values('" + _strId +"', 'email', '" + _strEmail + "');");
	        stmt.close();
	        conn.close();
	 		
	        System.out.println("mysql jdbc test: connect ok!!");
	        
	        
	        ret = 0;
	    }
	    catch( Exception ex )
	    {
	    	ex.printStackTrace();
	        
	    	ret = -1;
	    }
	
		return 0; 
	}
%>

<% 
	session = request.getSession(true);
	System.out.println("call");
	String strCmd = request.getParameter("cmd");
	System.out.println("call cmd" + strCmd);
	int bLoginPage = 0;
	
	String strId = request.getParameter("id");
	String strPwd = request.getParameter("pwd");
	String strEmail = request.getParameter("email");
	String strMe2dayId = request.getParameter("me2dayId");
	
	int ret = join(strId, strPwd, strEmail, strMe2dayId);
	
	if(ret == 0){
		out.println("ok");
		session.setAttribute("id",strId);
	}else{
		out.println("fail");
	}
%>

